<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="../css/style.css" />
<script language="javascript">
	function themanh()
	{
		slanh=document.tintuc.slanh.value;
		slanh=1+parseInt(slanh);
		document.tintuc.slanh.value=slanh;
		anh="Ảnh " + slanh + ": ";
		div=document.getElementById("themanh");
		br=document.createElement("br");
		div.appendChild(br);
		text=document.createTextNode(anh);
		div.appendChild(text);
		file=document.createElement("input");
		file.type="file";
		file.name="anh" + slanh;
		div.appendChild(file);
	}
	function ktra()
	{
		if(document.tintuc.tieude.value=='')
		{
			alert("Xin vui lòng nhập tiêu đề của tin!");
			document.tintuc.tieude.focus();
			return false;
		}
		else if(document.tintuc.tomluoc.value=='')
		{
			alert("Xin vui lòng nhập tóm lược của tin!");
			document.tintuc.tomluoc.focus();
			return false;
		}
		/*else if=============Kiểm tra nội dung*/
		else
			return true;
	}
</script>
</head>

<body>
	<?php
		/*if(isset($_GET['matt']))
		{
			$kq=$knoi->queryCsdl("select *");
		}*/
	?>
	<div style="margin-left:20px; margin-right:20px;">
	<p>TIN TỨC MỚI</p>
	<form action="home_admin.php" method="post" enctype="multipart/form-data" name="tintuc" onsubmit="return ktra();">
		<table align="center">
			<tr>
				<td class="stylelitle">Loại tin tức:<br /><input type="hidden" name="module" value="themtintuc" />
					<?php
						$loai=$_GET['loai'];
						$kq=$knoi->queryCsdl("select maloaitt,tenloai from loaitintuc where loai='$loai'");
					?>
					<select name="maloaitt">
						<?php
							while($n=mysql_fetch_array($kq))
							{
						?>
								<option value="<?php echo $n['maloaitt']; ?>"><?php echo $n['tenloai']; ?></option>
						<?php
							}
						?>
					</select>				</td>
			</tr>
			<tr>
				<td class="stylelitle">Tiêu đề:<br /><textarea name="tieude" cols="40" rows="2"><?php if(isset($_GET['tieude'])) echo $_GET['tieude']; ?></textarea></td>
			</tr>
			<tr>
				<td class="stylelitle">Tóm lược:<br />
			    <textarea name="tomluoc" cols="40" rows="3"><?php if(isset($_GET['tomluoc'])) echo $_GET['tomluoc']; ?></textarea></textarea></td>
			</tr>
			<tr>
				<td class="stylelitle">Nội dung:<br /><textarea name="noidung" id="idnoidung" cols="20" rows="3"><?php if(isset($_GET['noidung'])) echo $_GET['noidung']; ?></textarea></textarea><?php
					$CKEditor = new CKEditor();
					$CKEditor->basePath = 'ckeditor/';
					$CKEditor->replace("idnoidung");
				?></td>
			</tr>
			<script type="text/javascript" language="javascript">
   				 ckeditor.replace( 'idnoidung' );
			</script>
			<tr>
				<td class="stylelitle"><!--Ngày đăng:-->Trạng thái:<!--<input type="text" name="ngaydang" maxlength="10" />&nbsp;&nbsp;&nbsp;&nbsp;--><input type="radio" name="trangthai" value="1" checked="checked" />&nbsp;Đăng tin&nbsp;&nbsp;&nbsp;<input type="radio" name="trangthai" value="0" />&nbsp;Lưu</td></tr>
			<tr>
				<td class="stylelitle"><!--Ngày đăng:-->Ảnh kèm theo:<!--<input type="text" name="ngaydang" maxlength="10" />&nbsp;&nbsp;&nbsp;&nbsp;--></td></tr>
			<tr><td class="stylelitle" style="padding-left:40px;">
			<div id="themanh">
			Ảnh 1: <input type="file" name="anh1"/>
			</div>
			</td></tr>
			<tr><td style="padding-left:100px;"><input type="button" class="button" name="them" value="Thêm ảnh" onclick="themanh()" />
			  <input type="hidden" name="slanh" value="1" /></td></tr>
			</tr>
			<tr><td style="text-align:center"><input type="submit" class="button" value="Thêm tin tức" />&nbsp;<input class="button" type="reset" value="Hủy bỏ" /></td></tr>
		</table>
	</form>
	</div>
</body>
</html>
